<template>
  <div>
    <div class="user">
      <span>{{ users.mobile }}</span>
      <van-button type="danger" size="mini" @click="logout"
        >退出登录</van-button
      >
    </div>
    <transition>
      <van-notice-bar
        v-show="show"
        color="#A00000"
        left-icon="volume-o"
        text="在代码阅读过程中人们说脏话的频率是衡量代码质量的唯一标准。"
      />
    </transition>

    <van-button @click="show = !show">Toggle</van-button>
  </div>
</template>

<script>
export default {
  name: "",
  data() {
    return {
      users: {},
      show: true,
    };
  },
  mounted() {
    let url = this.$store.state.mobile.yxUrl;
    let token = this.$store.state.mobile.token;

    let formdata = new FormData();
    formdata.append("token", token);

    this.$axios.post(`${url}/user/detail`, formdata).then((res) => {
      console.log(res);
      this.users = res.data.base;
    });
  },
  beforeRouteEnter(to, from, next) {
    next((vm) => {
      console.log(vm.$store.state);
      if (vm.$store.state.mobile.token == "") {
        vm.$router.push("/m/login");
      }
    });
  },
  methods: {
    //执行退出的方法
    logout() {
      this.$store.commit("mobile/logout");
      this.$router.push("/m/login");
    },
  },
  computed: {},
  watch: {},
};
</script>

<style scoped>
.v-enter, .v-leave-to{
  transform: translate(-100%,400%);
}

/* .v-enter-to{
  transform: translateX();
} */
.v-enter-active,.v-leave-active{
  transition: all 3s ease;
}

</style>